﻿using MODEL;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;

namespace DAL
{
    public class CarrierDAL
    {
        #region 显示历史承运单信息
        /// <summary>
        /// 显示历史承运单信息
        /// </summary>
        /// <param name = "carrier" ></ param >
        /// < returns ></ returns >
        public List<CarrierinfoMODEL> Get_carrierinfo(CarrierMODEL carrier)
        {
            StringBuilder strbuilder = new StringBuilder();
            strbuilder.Append(@"SELECT c.CarriersID,u.UserName,c.SendLinkman,c.SendCompany,c.ReceiveLinkman,
                                      c.ReceiveCompany,c.LeaverDate,c.TotalCost FROM dbo.Carriers AS c INNER JOIN 
                                      dbo.[User] AS u  ON u.UserID = c.FK_UserID");
            List<string> listwhere = new List<string>();
            List<SqlParameter> listparm = new List<SqlParameter>();
            #region 查询条件
            //承运单号
            if (carrier.CarriersID != 0)
            {
                listwhere.Add("CarriersID=@CarriersID");
                listparm.Add(new SqlParameter("@CarriersID", carrier.CarriersID));
            }
            //承运日期（开始)
            if (carrier.LeaverDate_in != null)
            {
                listwhere.Add("LeaverDate>=@LeaverDate_in");
                listparm.Add(new SqlParameter("@LeaverDate_in", carrier.LeaverDate_in));
            }
            //承运日期（结束）
            if (carrier.LeaverDate_end != null)
            {
                listwhere.Add("LeaverDate<=@LeaverDate_end");
                listparm.Add(new SqlParameter("@LeaverDate_end", carrier.LeaverDate_end));
            }
            //收货人
            if (!String.IsNullOrWhiteSpace(carrier.ReceiveLinkman))
            {
                listwhere.Add("ReceiveLinkman=@ReceiveLinkman");
                listparm.Add(new SqlParameter("@ReceiveLinkman", carrier.ReceiveLinkman));
            }
            // 收货日期（开始）
            if (carrier.ReceiveDate_in != null)
            {
                listwhere.Add("ReceiveDate>=@ReceiveDate_in");
                listparm.Add(new SqlParameter("@ReceiveDate_in", carrier.ReceiveDate_in));
            }
            //收货日期（结束）
            if (carrier.ReceiveDate_end != null)
            {
                listwhere.Add("ReceiveDate<=@ReceiveDate_end");
                listparm.Add(new SqlParameter("@ReceiveDate_end", carrier.ReceiveDate_end));
            }
            //发货人
            if (!string.IsNullOrWhiteSpace(carrier.SendLinkman))
            {
                listwhere.Add("SendLinkman=@SendLinkman");
                listparm.Add(new SqlParameter("@SendLinkman", carrier.SendLinkman));
            }
            //业务员
            if (!string.IsNullOrWhiteSpace(carrier.UserName))
            {
                listwhere.Add("UserName=@UserName");
                listparm.Add(new SqlParameter("@UserName", carrier.UserName));
            }
            //判断是否有条件
            if (listparm.Count > 0)
            {
                strbuilder.Append($" where {string.Join(" and ", listwhere.ToArray())}");
            }
            #endregion
            DataTable dt = DBhelper.SqlDataAdapter(strbuilder.ToString(), listparm.ToArray());
            List<CarrierinfoMODEL> list = new List<CarrierinfoMODEL>();
            foreach (DataRow dr in dt.Rows)
            {
                CarrierinfoMODEL infomodel = new CarrierinfoMODEL()
                {
                    CarriersID = Convert.ToInt32(dr["CarriersID"]),
                    //UserID = Convert.ToInt32(dr["UserID"]),
                    UserName = dr["UserName"].ToString(),
                    SendLinkman = dr["SendLinkman"].ToString(),
                    SendCompany = dr["SendCompany"].ToString(),
                    ReceiveLinkman = dr["ReceiveLinkman"].ToString(),
                    ReceiveCompany = dr["ReceiveCompany"].ToString(),
                    LeaverDate = Convert.ToDateTime(dr["LeaverDate"]),
                    TotalCost = float.Parse(dr["TotalCost"].ToString())
                };
                list.Add(infomodel);
            }
            return list;
        }
        #endregion

        #region 承运单维护查询
        /// <summary>
        /// 承运单维护查询
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public List<CarrierinfoMODEL> GetCarriesList(CarrierMODEL model)
        {
            StringBuilder builder = new StringBuilder();
            builder.Append(@"SELECT c.CarriersID, CASE FinishedState 
                             WHEN 0 THEN '待调度'
                             WHEN 1 THEN '已调度'
                             WHEN 2 THEN '已签收'
                             else '已结算' end as FinishedState
,c.SendLinkman,c.SendCompany,c.ReceiveLinkman,c.ReceiveCompany,c.LeaverDate,c.TotalCost,
CASE c.IsDelete WHEN 0 THEN '使用中' ELSE '该记录已删除' END AS IsDelete 
FROM dbo.Carriers AS c 
INNER JOIN dbo.[User] AS u  ON u.UserID = c.FK_UserID");

            List<string> liststr = new List<string>();
            List<SqlParameter> listparm = new List<SqlParameter>();
            //承运单号
            if (model.CarriersID != 0)
            {
                liststr.Add("CarriersID=@CarriersID");
                listparm.Add(new SqlParameter("@CarriersID", model.CarriersID));
            }
            //承运日期（开始）
            if (model.LeaverDate_in == null)
            {
                liststr.Add("LeaverDate_in=@LeaverDate_in");
                listparm.Add(new SqlParameter("@LeaverDate_in", model.LeaverDate_in));
            }
            //承运日期（结束）
            if (model.LeaverDate_end == null)
            {
                liststr.Add("LeaverDate_end=@LeaverDate_end");
                listparm.Add(new SqlParameter("@LeaverDate_end", model.LeaverDate_end));
            }
            //收货人
            if (!string.IsNullOrWhiteSpace(model.ReceiveLinkman))
            {
                liststr.Add("ReceiveLinkman=@ReceiveLinkman");
                listparm.Add(new SqlParameter("@ReceiveLinkman", model.ReceiveLinkman));
            }
            //发货人
            if (!string.IsNullOrWhiteSpace(model.SendLinkman))
            {
                liststr.Add("SendLinkman=@SendLinkman");
                listparm.Add(new SqlParameter("@SendLinkman", model.SendLinkman));
            }
            if (listparm.Count > 0)
            {
                builder.Append($" where{ string.Join(" and", liststr.ToArray())}");
            }
            DataTable table = DBhelper.SqlDataAdapter(builder.ToString(), listparm.ToArray());
            List<CarrierinfoMODEL> list = new List<CarrierinfoMODEL>();
            foreach (DataRow row in table.Rows)
            {
                CarrierinfoMODEL carr = new CarrierinfoMODEL()
                {
                    CarriersID = Convert.ToInt32(row["CarriersID"]),
                    SendLinkman = row["SendLinkman"].ToString(),
                    SendCompany = row["SendCompany"].ToString(),
                    ReceiveLinkman = row["ReceiveLinkman"].ToString(),
                    ReceiveCompany = row["ReceiveCompany"].ToString(),
                    LeaverDate = Convert.ToDateTime(row["LeaverDate"]),
                    TotalCost = float.Parse(row["TotalCost"].ToString()),
                    IsDelete=row["IsDelete"].ToString()
                };
                list.Add(carr);
            }
            return list;
        }
        #endregion

        #region 运单详情
        public DataTable GetXingQing(int carrid)
        {
            string sql = "SELECT * FROM dbo.Carriers where CarriersID=@CarriersID";
            SqlParameter[] parm = {
                        new SqlParameter("@CarriersID",carrid)
                    };

            return DBhelper.SqlDataAdapter(sql, parm);
        }
        #endregion

        #region 成本维护
        /// <summary>
        /// 成本维护
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public List<CarrierinfoMODEL> GetCarrerInfo(CarrierMODEL model)
        {
            StringBuilder bulider = new StringBuilder();
            bulider.Append(@"SELECT cr.CarriersID,ur.UserName,cr.SendCompany,cr.ReceiveDate,cr.TransportCost,cr.FinishedState 
        FROM dbo.Carriers AS cr INNER JOIN dbo.[User] AS ur ON ur.UserID = cr.FK_UserID");
            List<string> listwhere = new List<string>();
            List<SqlParameter> listparm = new List<SqlParameter>();
            //状态
            if (model.FinishedState != 0)
            {
                listwhere.Add("FinishedState=@FinishedState");
                listparm.Add(new SqlParameter("@FinishedState", model.FinishedState));
            }
            //接收时间（开始）
            if (model.ReceiveDate_in != null)
            {
                listwhere.Add("ReceiveDate_in=@ReceiveDate_in");
                listparm.Add(new SqlParameter("@ReceiveDate_in", model.ReceiveDate_in));
            }
            //接收时间（结束）
            if (model.ReceiveDate_end != null)
            {
                listwhere.Add("ReceiveDate_end=@ReceiveDate_end");
                listparm.Add(new SqlParameter("@ReceiveDate_end", model.ReceiveDate_end));
            }
            //判断条件
            if (listparm.Count > 0)
            {
                bulider.Append($" where {string.Join(" and ", listwhere.ToArray())}");
            }
            DataTable table = DBhelper.SqlDataAdapter(bulider.ToString(), listparm.ToArray());
            List<CarrierinfoMODEL> list = new List<CarrierinfoMODEL>();
            foreach (DataRow row in table.Rows)
            {
                CarrierinfoMODEL info = new CarrierinfoMODEL()
                {
                    CarriersID = Convert.ToInt32(row["CarriersID"]),
                    UserName = row["UserName"].ToString(),
                    SendCompany = row["SendCompany"].ToString(),
                    ReceiveDate = Convert.ToDateTime(row["ReceiveDate"]),
                    TotalCost = float.Parse(row["TotalCost"].ToString()),
                    FinishedState = Convert.ToInt32(row["FinishedState"])
                };
                list.Add(info);
            }
            return list;
        }
        #endregion

        #region 多条语句查询承运单

        public List<CarrierinfoMODEL> GetCarriers(CarrierMODEL car)
        {
            StringBuilder builder = new StringBuilder();
            //查询语句
            builder.Append(@"select CarriersID,SendLinkman,SendCompany,ReceiveLinkman,ReceiveCompany, LeaverDate,TotalCost,
                             CASE FinishedState 
                             WHEN 0 THEN '待调度'
                             WHEN 1 THEN '已调度'
                             WHEN 2 THEN '已签收'
                             else '已结算' end as FinishedState
                             from Carriers");
            //定义查询列表和参数列表
            List<string> listWhere = new List<string>();
            List<SqlParameter> listParam = new List<SqlParameter>();
            //承运单id
            if (car.CarriersID > 0)
            {
                listWhere.Add("CarriersID=@CarriersID");
                listParam.Add(new SqlParameter("@CarriersID", car.CarriersID));
            }
            //收货人
            if (!string.IsNullOrWhiteSpace(car.ReceiveLinkman))
            {
                listWhere.Add("ReceiveLinkman=@ReceiveLinkman");
                listParam.Add(new SqlParameter("@ReceiveLinkman", car.ReceiveLinkman));
            }
            if (listWhere.Count > 0)
            {
                builder.Append($" where {string.Join(" and ", listWhere.ToArray())}");
            }
            SqlDataReader reader = DBhelper.ExecuteReader(builder.ToString(), listParam.ToArray());
            List<CarrierinfoMODEL> listmode = new List<CarrierinfoMODEL>();
            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    CarrierinfoMODEL userm = new CarrierinfoMODEL();
                    userm.CarriersID = Convert.ToInt32(reader["CarriersID"]);
                    userm.SendLinkman = Convert.ToString(reader["SendLinkman"]);
                    userm.SendCompany = Convert.ToString(reader["SendCompany"]);
                    userm.ReceiveLinkman = Convert.ToString(reader["ReceiveLinkman"]);
                    userm.ReceiveCompany = Convert.ToString(reader["ReceiveCompany"]);
                    userm.LeaverDate = Convert.ToDateTime(reader["LeaverDate"]);
                    userm.TotalCost = float.Parse(reader["TotalCost"].ToString());
                    userm.FinishedState = Convert.ToInt32(reader["FinishedState"]);
                    listmode.Add(userm);
                }
            }
            return listmode;
        }
        #endregion

        #region 根据id查询
        public CarrierMODEL GetCarriersID(int ID)
        {
            string sql = @"select * from Carriers WHERE CarriersID=@CarriersID";
            //定义查询列表和参数列表
            SqlParameter[] parm = {
                new SqlParameter("@CarriersID",ID)
            };
            SqlDataReader reader = DBhelper.ExecuteReader(sql, parm);
            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    CarrierMODEL userm = new CarrierMODEL();
                    userm.CarriersID = Convert.ToInt32(reader["CarriersID"]);
                    userm.SendLinkman = Convert.ToString(reader["SendLinkman"]);
                    userm.SendCompany = Convert.ToString(reader["SendCompany"]);
                    userm.SendAddress = Convert.ToString(reader["SendAddress"]);
                    userm.SendPhone = Convert.ToString(reader["SendPhone"]);
                    userm.ReceiveLinkman = Convert.ToString(reader["ReceiveLinkman"]);
                    userm.ReceiveCompany = Convert.ToString(reader["ReceiveCompany"]);
                    userm.FK_ReceiveAddress = Convert.ToString(reader["FK_ReceiveAddress"]);
                    userm.ReceviePhone = Convert.ToString(reader["ReceviePhone"]);
                    userm.InsuranceCosst = float.Parse(Convert.ToString(reader["InsuranceCosst"]));
                    userm.TransportCost = float.Parse(Convert.ToString(reader["TransportCost"]));
                    userm.OtherCost = float.Parse(Convert.ToString(reader["OtherCost"]));
                    return userm;
                }
            }
            return null;
        }
        #endregion


        #region 承运单详情查询语句
        /// <summary>
        /// 承运单详情查询语句
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public CarrierMODEL GetSelet(int ID)
        {
            string str = @"select *  from Carriers as c left join dbo.[User] as u on c.FK_UserID=u.UserID where CarriersID=@CarriersID";
            SqlParameter[] parm = {
                new SqlParameter("@CarriersID",ID)
            };
            SqlDataReader reader = DBhelper.ExecuteReader(str, parm);
            List<CarrierMODEL> list = new List<CarrierMODEL>();
            if (reader.HasRows)
            {
                if (reader.Read())
                {
                    CarrierMODEL userm = new CarrierMODEL();
                    userm.CarriersID = Convert.ToInt32(reader["CarriersID"]);
                    userm.SendCompany = Convert.ToString(reader["SendCompany"]);
                    userm.SendLinkman = Convert.ToString(reader["SendLinkman"]);
                    userm.SendAddress = Convert.ToString(reader["SendAddress"]);
                    userm.SendPhone = Convert.ToString(reader["SendPhone"]);
                    userm.FK_ReceiveAddress = Convert.ToString(reader["FK_ReceiveAddress"]);
                    userm.ReceiveLinkman = Convert.ToString(reader["ReceiveLinkman"]);
                    userm.ReceviePhone = Convert.ToString(reader["ReceviePhone"]);
                    userm.UserName = Convert.ToString(reader["UserName"]);
                    userm.CheckInTime = Convert.ToDateTime(reader["CheckInTime"]);
                    userm.LeaverDate = Convert.ToDateTime(reader["LeaverDate"]);
                    userm.ReceiveDate = Convert.ToDateTime(reader["ReceiveDate"]);
                    userm.FinishedState = Convert.ToInt32(reader["FinishedState"]);
                    userm.OtherCost = float.Parse(Convert.ToString(reader["OtherCost"]));
                    userm.InsuranceCosst = float.Parse(Convert.ToString(reader["InsuranceCosst"]));
                    userm.TransportCost = float.Parse(Convert.ToString(reader["TransportCost"]));
                    userm.TotalCost = float.Parse(Convert.ToString(reader["TotalCost"]));
                    userm.Remark = reader["Remark"] as string;
                    return userm;
                }
            }
            return null;
        }
        #endregion

        #region 存储过程查询承运单管理
        /// <summary>
        /// 存储过程查询承运单
        /// </summary>
        /// <param name="carriersd"></param>
        /// <param name="ReceiveLinkman"></param>
        /// <param name="PageIndex"></param>
        /// <param name="PageSize"></param>
        /// <param name="TotalCount"></param>
        /// <returns></returns>
        public List<CarrierinfoMODEL> GetPagesCarriers(string CarriersID, string ReceiveLinkman, string SendLinkman, string startTime, string endTime,
            int PageIndex, int PageSize, out int TotalCount)
        {
            TotalCount = 0;
            List<CarrierinfoMODEL> cariser = new List<CarrierinfoMODEL>();
            string procName = "proc_GetPagesCarriers";
            SqlParameter[] parm = {
                new SqlParameter("@CarriersID",CarriersID),
                new SqlParameter("@ReceiveLinkman",ReceiveLinkman),
                new SqlParameter("@SendLinkman",SendLinkman),
                new SqlParameter("@StartLeaverDate",startTime),
                new SqlParameter("@EndLeaverDate",endTime),
                new SqlParameter("@PageIndex",PageIndex),
                new SqlParameter("@PageSize",PageSize),
                new SqlParameter("@TotalCount",TotalCount)
            };
            parm[7].Direction = ParameterDirection.Output;
            SqlDataReader reader = DBhelper.ExecuteReaderProc(procName, parm);
            List<CarrierinfoMODEL> listmode = new List<CarrierinfoMODEL>();
            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    CarrierinfoMODEL userm = new CarrierinfoMODEL();
                    userm.CarriersID = Convert.ToInt32(reader["CarriersID"]);
                  //  userm.UserName = reader["UserName"].ToString();
                    userm.SendLinkman = Convert.ToString(reader["SendLinkman"]);
                    userm.SendCompany = Convert.ToString(reader["SendCompany"]);
                    userm.ReceiveLinkman = Convert.ToString(reader["ReceiveLinkman"]);
                    userm.ReceiveCompany = Convert.ToString(reader["ReceiveCompany"]);
                    userm.LeaverDate = Convert.ToDateTime(reader["LeaverDate"]);
                    userm.TotalCost = float.Parse(reader["TotalCost"].ToString());
                    userm.FinishedState = Convert.ToInt32(reader["FinishedState"]);
                    listmode.Add(userm);
                }
                reader.Close();
                TotalCount = Convert.ToInt32(parm[7].Value);
            }
            return listmode;
        }
        #endregion

        #region 修改承运单
        /// <summary>
        /// 修改承运单
        /// </summary>
        /// <param name="carm"></param>
        /// <returns></returns>
        public int UpCarriage(CarrierinfoMODEL carm)
        {
            string update = @"update Carriers set   SendCompany=@SendCompany,SendAddress=@SendAddress,
                                        SendPhone=@SendPhone,SendLinkman=@SendLinkman,ReceiveCompany=@ReceiveCompany,
                      FK_ReceiveAddress=@FK_ReceiveAddress,ReceviePhone=@ReceviePhone, ReceiveLinkman=@ReceiveLinkman,
                               InsuranceCosst=@InsuranceCosst,TransportCost=@TransportCost,OtherCost=@OtherCost,
                           AlterTime=@AlterTime  where CarriersID=@CarriersID";
            SqlParameter[] parm = {
                new SqlParameter("@SendCompany",carm.SendCompany),
                new SqlParameter("@SendAddress",carm.SendAddress),
                new SqlParameter("@SendPhone",carm.SendPhone),
                new SqlParameter("@SendLinkman",carm.SendLinkman),
                new SqlParameter("@ReceiveCompany",carm.ReceiveCompany),
                new SqlParameter("@FK_ReceiveAddress",carm.FK_ReceiveAddress),
                new SqlParameter("@ReceivePhone",carm.ReceviePhone),
                new SqlParameter("@ReceiveLinkman",carm.ReceiveLinkman),
                new SqlParameter("@InsuranceCost",carm.InsuranceCosst),
                new SqlParameter("@TransportCost",carm.TransportCost),
                new SqlParameter("@OtherCost",carm.OtherCost),
                new SqlParameter("@AlterTime",DateTime.Now),
                new SqlParameter("@CarriersID",carm.CarriersID)
            };
            return DBhelper.ExecuteNonQuery(update, parm);
        }
        #endregion

        #region 接收签收承运单
        /// <summary>
        /// 接收承运单签收
        /// </summary>
        /// <param name="CarrierID"></param>
        /// <returns></returns>
        public int UpAccept(int CarrierID)
        {
            string update = "update Carriers set FinishedState=2 where CarriersID=@CarrierID";
            SqlParameter[] parm = {
                new SqlParameter("@CarrierID",CarrierID)
            };
            return DBhelper.ExecuteNonQuery(update, parm);
        }
        #endregion
        //update Carriers set ReceiveDate=getdate(),FinishedState=2 where CarriersID=1
        #region update
        public int ReceiveAccept(int CarrierID)
        {
            string update = "update Carriers set ReceiveDate=@ReceiveDate,FinishedState=2 where CarriersID=@CarriersID";
            SqlParameter[] parm = {
                new SqlParameter("@ReceiveDate",DateTime.Now),
                new SqlParameter("@CarriersID",CarrierID)
            };
            return DBhelper.ExecuteNonQuery(update, parm);
        }
        #endregion


        #region 修改
        /// <summary>
        /// 修改逻辑判断
        /// </summary>
        /// <param name="CarrierID"></param>
        /// <returns></returns>
        public int UpAcceptAlert(int CarrierID)
        {
            string sql = "select count(*) from Carriers where FinishedState=2 and CarriersID=@CarriersID";
            SqlParameter[] pams = { new SqlParameter("@CarriersID", CarrierID) };
            return Convert.ToInt32(DBhelper.SqlDataAdapter(sql, pams));
        }
        #endregion

        #region 删除承运单
        /// <summary>
        /// 删除承运单
        /// </summary>
        /// <param name="CarrierID"></param>
        /// <returns></returns>
        public int DelCarriage(int CarrierID)
        {
            string Delete = "update Carriers set IsDelete=1 where CarriersID=@CarriersID";
            SqlParameter[] parm = {
                new SqlParameter("@CarriersID",CarrierID)
            };
            return DBhelper.ExecuteNonQuery(Delete, parm);
        }
        #endregion

        #region 删除
        /// <summary>
        /// 删除逻辑判断
        /// </summary>
        /// <param name="DriverID"></param>
        /// <returns></returns>
        public int DeleteCarriage(int CarrierID)
        {
            string sql = "select count(*) from Carriers where IsDelete=1 and CarriersID=@CarriersID";
            SqlParameter[] pams = { new SqlParameter("@CarriersID", CarrierID) };
            return Convert.ToInt32(DBhelper.SqlDataAdapter(sql, pams));
        }
        #endregion

        #region 插入承运单信息
        /// <summary>
        /// 插入承运单信息
        /// </summary>
        /// <param name="carm"></param>
        /// <returns></returns>
        public int InsertCarriage(CarrierinfoMODEL carm)
        {
            string update = @"insert into Carriers values(@SendCompany,@SendAddress,@SendLinkman,
                              @SendPhone,@ReceiveCompany,@FK_ReceiveAddress,
                              @ReceiveLinkman,@ReceviePhone,@LeaverDate,@ReceiveDate,
                              @FinishedState,@InsuranceCosst,@TransportCost,@OtherCost,
                              @TotalCost,@Remark,@FK_UserID,@CheckInTime,@IsDelete,@AlterTime)";
            SqlParameter[] parm = {
                new SqlParameter("@SendCompany",carm.SendCompany),
                new SqlParameter("@SendAddress",carm.SendAddress),
                new SqlParameter("@SendLinkman",carm.SendLinkman),
                new SqlParameter("@SendPhone",carm.SendPhone),
                new SqlParameter("@ReceiveCompany",carm.ReceiveCompany),
                new SqlParameter("@FK_ReceiveAddress",carm.FK_ReceiveAddress),
                new SqlParameter("@ReceiveLinkman",carm.ReceiveLinkman),
                new SqlParameter("@ReceivePhone",carm.ReceviePhone),
                new SqlParameter("@LeaverDate",DateTime.Now),
                new SqlParameter("@ReceiveDate",DateTime.Now),
                new SqlParameter("@FinishedState",carm.FinishedState),
                new SqlParameter("@InsuranceCost",carm.InsuranceCosst),
                new SqlParameter("@TransportCost",carm.TransportCost),
                new SqlParameter("@OtherCost",carm.OtherCost),
                new SqlParameter("@TotalCost",carm.TotalCost),
                new SqlParameter("@Remark",carm.Remark),
                new SqlParameter("@UserID",carm.UserID),
                new SqlParameter("@CheckInTime",DateTime.Now),
                new SqlParameter("@IsDelete",carm.IsDelete),
                new SqlParameter("@AlterTime",DateTime.Now),
            };
            return DBhelper.ExecuteNonQuery(update, parm);
        }
        #endregion
    }
}
